package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingBloodOxygenDetail;
import com.ruoyi.ring.service.IRingBloodOxygenDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 血氧详情Controller
 * 
 * @author liuwp
 * @date 2025-09-03
 */
@RestController
@RequestMapping("/ring/ring_blood_oxygen_detail")
public class RingBloodOxygenDetailController extends BaseController
{
    @Autowired
    private IRingBloodOxygenDetailService ringBloodOxygenDetailService;

    /**
     * 查询血氧详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingBloodOxygenDetail ringBloodOxygenDetail)
    {
        startPage();
        List<RingBloodOxygenDetail> list = ringBloodOxygenDetailService.selectRingBloodOxygenDetailList(ringBloodOxygenDetail);
        return getDataTable(list);
    }

    /**
     * 导出血氧详情列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:export')")
    @Log(title = "血氧详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingBloodOxygenDetail ringBloodOxygenDetail)
    {
        List<RingBloodOxygenDetail> list = ringBloodOxygenDetailService.selectRingBloodOxygenDetailList(ringBloodOxygenDetail);
        ExcelUtil<RingBloodOxygenDetail> util = new ExcelUtil<RingBloodOxygenDetail>(RingBloodOxygenDetail.class);
        util.exportExcel(response, list, "血氧详情数据");
    }

    /**
     * 获取血氧详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringBloodOxygenDetailService.selectRingBloodOxygenDetailById(id));
    }

    /**
     * 新增血氧详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:add')")
    @Log(title = "血氧详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingBloodOxygenDetail ringBloodOxygenDetail)
    {
        return toAjax(ringBloodOxygenDetailService.insertRingBloodOxygenDetail(ringBloodOxygenDetail));
    }

    /**
     * 修改血氧详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:edit')")
    @Log(title = "血氧详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingBloodOxygenDetail ringBloodOxygenDetail)
    {
        return toAjax(ringBloodOxygenDetailService.updateRingBloodOxygenDetail(ringBloodOxygenDetail));
    }

    /**
     * 删除血氧详情
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen_detail:remove')")
    @Log(title = "血氧详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringBloodOxygenDetailService.deleteRingBloodOxygenDetailByIds(ids));
    }

}
